<?php

class Bus_IndexController extends App_Controller_Action
{
    public function indexAction()
    {
        $this->view->headScript()->appendFile(BASE_URL . '/js/app/bus/bus.js');
        $this->view->headScript()->appendFile(BASE_URL . '/js/app/bus/bus_init.js');
        $this->view->headLink()->appendStylesheet(BASE_URL . '/css/app/bus/bus.css');
        $this->view->formBus = new Bus_Form_Bus();
        $this->view->formStop = new Bus_Form_Stop();

        $this->render();
    }

    public function pathAction()
    {
        $auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity()) {
            $pathFinder = new Bus_Model_PathFinder();
            $from = $this->getRequest()->getParam('from', 0);
            $to = $this->getRequest()->getParam('to', 0);
            if ($from && $to) {
                $path = $pathFinder->getPath($from, $to);
                $this->_helper->json->sendJson(array('path' => implode(",", $path)));
            }
        }
    }
}